<template>
	<!--  库存详情-->
	<div class="content">
		<div class="pageSearchView">
			<el-form :inline="true" :model="searchParam">
				<el-form-item label="GRN编号">
					<el-input v-model="searchParam.batch" placeholder="请输入GRN编号" clearable style="width: 125px" />
				</el-form-item>
				<el-form-item label="物料">
					<el-select v-model="searchParam.materialId" placeholder="请选择物料" clearable filterable style="width: 125px">
						<el-option v-for="item in materiaList" :key="item.value" :label="item.label" :value="item.value" />
					</el-select>
				</el-form-item>
				<el-form-item label="物料状态">
					<el-select v-model="searchParam.materialStatus" placeholder="请选择" clearable filterable style="width: 125px">
						<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value" />
					</el-select>
				</el-form-item>
				<el-form-item label="加工属性">
					<el-select v-model="searchParam.processingStatus" placeholder="请选择" clearable filterable style="width: 125px">
						<el-option v-for="item in materialStatusList" :key="item.value" :label="item.label" :value="item.value" />
					</el-select>
				</el-form-item>
				<el-form-item label="仓库">
					<el-tree-select v-model="searchParam.warehouseId" :data="wareList" check-strictly clearable filterable
													:render-after-expand="false" :props="{
              children: 'sonList',
              label: 'warehouseName',
              value: 'id',
            }" style="width: 125px" @change="wareChange" />
				</el-form-item>
				<el-form-item label="库位">
					<el-select v-model="searchParam.storageId" placeholder="请选择" clearable filterable style="width: 125px">
						<el-option v-for="item in storageList" :key="item.id" :label="item.storageName" :value="item.id" />
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" :icon="Search" @click="getList()">查询</el-button>
					<el-button :icon="Refresh" @click="resetSearch()">重置</el-button>
				</el-form-item>
			</el-form>
		</div>
		<div class="pageTableView">
			<div class="pageTableMenuView">
				<div class="pageTableTitle">
					<div>列表信息</div>
				</div>
				<!-- <div class="pageTableButView">
				 <el-button type="primary" @click="qrCodeSplit" :disabled="multipleSelection.length !== 1">二维码拆分</el-button>
				 <el-button type="primary" @click="qrCodePush" :disabled="multipleSelection.length == 0">二维码合并</el-button>
				 <el-button type="primary" @click="printClick" :disabled="multipleSelection.length == 0">报工总数打印</el-button>
			 </div> -->
			</div>
			<!-- 表格 -->
			<el-table :data="paginatedData" height="calc(100vh - 320px)" row-key="id" stripe="false" border show-summary
								:summary-method="getSummaries"
								@selection-change="handleSelectionChange" header-cell-class-name="witheTableHeader">
				<el-table-column type="selection" width="55" align="center" sortable />
				<el-table-column label="序号" align="center" width="55">
					<template #default="scope"> {{ (currentPage - 1) * pageSize + scope.$index + 1 }}</template>
				</el-table-column>
				<!--        <el-table-column label="批次号" prop="batchNo" min-width="200" show-overflow-tooltip align="center" sortable  />-->
				<!--        <el-table-column label="物料名称" prop="materialName" min-width="200" show-overflow-tooltip align="center" sortable  />-->
				<el-table-column label="物料编码" prop="materialNo" min-width="200" show-overflow-tooltip align="center" sortable />
				<el-table-column label="数量" prop="count" min-width="150" show-overflow-tooltip align="center" sortable />
				<el-table-column label="单位" prop="basicUnit" min-width="150" show-overflow-tooltip align="center" sortable />
				<!--        <el-table-column label="物料状态" prop="materialStatus" align="center" sortable  min-width="150" :formatter="formatStatus" />-->
				<!--        <el-table-column label="加工属性" prop="processingStatus" align="center" sortable  min-width="150"-->
				<!--          :formatter="formatProcessingAttributes" />-->
				<el-table-column label="GRN编号" prop="batch" min-width="250" show-overflow-tooltip align="center" sortable />
				<el-table-column label="库位名称" prop="storageName" min-width="200" show-overflow-tooltip align="center"
												 sortable />
				<el-table-column label="追溯码" prop="traceabilityCode" min-width="250" show-overflow-tooltip align="center"
                         sortable />
        <el-table-column label="炉号" prop="heatNumber" min-width="150" show-overflow-tooltip align="center"
                         sortable />
        <el-table-column label="模号" prop="registerName" min-width="150" show-overflow-tooltip align="center"
                         sortable />
				<!--				<el-table-column label="转码前追溯码" prop="preorderTraceCode" min-width="250" show-overflow-tooltip align="center"-->
				<!--												 sortable />-->
				<el-table-column label="创建时间" prop="createTime" min-width="200" show-overflow-tooltip align="center" sortable />
				<el-table-column label="创建人" prop="createUserName" min-width="200" show-overflow-tooltip align="center"
												 sortable />
				<!--        <el-table-column label="操作" width="200" align="center" sortable  fixed="right">-->
				<!--          <template #default="scope">-->
				<!--            <el-button type="text" size="small" :icon="Tickets" @click="handleEdit(scope.row,1)">驳回</el-button>-->
				<!--            <el-button type="text" size="small" :icon="DocumentChecked-->
				<!--" @click="doFinish(scope.row)">入库确认-->
				<!--            </el-button>-->
				<!--            &lt;!&ndash;            <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>&ndash;&gt;-->
				<!--            &lt;!&ndash;            <el-button type="text" size="small" @click="handleDel(scope.row)">删除</el-button>&ndash;&gt;-->
				<!--          </template>-->
				<!--        </el-table-column>-->
			</el-table>
			<div class="pagePagination">
				<el-pagination background layout="sizes, prev,pager, next,total" :total="pageTotal" :page-size="pageSize"
											 :current-page="currentPage" @size-change="handleSizeChange"
											 @current-change="handleCurrentChange" />
			</div>
		</div>
		<!-- 编辑/新建弹框 -->
		<el-dialog v-model="showCrud" :title="crudTitle + '入库单'" width="1000px">
			<el-form :model="formData" label-width="100px">
				<el-row :gutter="10">
					<el-col :span="8">
						<el-form-item label="工序订单" prop="procedureOrderId">
							<el-select v-model="formData.procedureOrderId" placeholder="请选择工序订单" clearable filterable
												 style="width: 125px" :disabled="popType == 1">
								<el-option v-for="item in procedureOrderList" :key="item.id" :label="item.planNo" :value="item.id" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="入库仓库">
							<el-tree-select v-model="formData.wareId" :data="wareList" :disabled="popType == 1" check-strictly
															:render-after-expand="false" :props="{
                  children: 'sonList',
                  label: 'warehouseName',
                  value: 'id',
                }" style="width: 125px" @change="wareChange" />
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="入库库位" prop="targetStorageId">
							<el-select v-model="formData.targetStorageId" :disabled="popType == 1" placeholder="请选择"
												 style="width: 125px">
								<el-option v-for="item in storageList" :key="item.id" :label="item.storageName" :value="item.id" />
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row :gutter="10">
					<div class="pageTableTitle">物料列表</div>
				</el-row>
				<el-row :gutter="10" style="padding: 10px">
					<el-table :data="formData.details" style="width:100% " height="calc(100vh - 600px)">
						<el-table-column label="序号" type="index" align="center" sortable width="80" />
						<el-table-column prop="materialId" label="物料编码" align="center" sortable>
							<template #default="scope">
								<el-select v-model="scope.row.materialId" :disabled="popType == 1" placeholder="" clearable filterable>
									<el-option v-for="item in materiaList" :key="item.value" :label="item.label" :value="item.value" />
								</el-select>
							</template>
						</el-table-column>
						<el-table-column prop="materialCount" label="数量" align="center" sortable width="150">
							<template #default="scope">
								<el-input v-model="scope.row.materialCount" type="number" :disabled="popType == 1"
													placeholder=""></el-input>
							</template>
						</el-table-column>
						<el-table-column prop="batchNo" label="批次号" align="center" sortable>
							<template #default="scope">
								<el-input v-model="scope.row.batchNo" placeholder="" :disabled="popType == 1"
													style="width: 100%"></el-input>
							</template>
						</el-table-column>
						<el-table-column align="center" sortable width="110" fixed="right" v-if="popType != 1">
							<template #header>
								<el-button :icon="Plus" @click="handleAddConfigLine">新建</el-button>
							</template>
							<template #default="scope">
								<!--                <el-button @click="handleEditConfigLine(scope.row,scope.$index)"-->
								<!--                           plain :icon="Edit">-->
								<!--                  编辑-->
								<!--                </el-button>-->
								<el-button type="danger" plain :icon="Delete" @click="handleConfigDelete(scope.$index)"> 删除</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-row>
			</el-form>
			<template #footer>
        <span class="dialog-footer">
          <el-button @click="showCrud = false">取消</el-button>
          <el-button type="primary" @click="handleSave">保存</el-button>
        </span>
			</template>
		</el-dialog>
		<!-- 查看详情弹框 -->
		<el-dialog v-model="showDetail" :title="crudTitle + '入库单'" width="1000px">
			<el-form :model="formData" label-width="100px">
				<el-row :gutter="10">
					<el-col :span="8">
						<el-form-item label="工序订单："> {{ formData.procedureOrderName || '--' }}</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="入库仓库："> {{ formData.targetWarehouseName || '--' }}</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="入库库位："> {{ formData.targetStorageName || '--' }}</el-form-item>
					</el-col>
				</el-row>
				<el-row :gutter="10">
					<div class="pageTableTitle">物料列表</div>
				</el-row>
				<el-row :gutter="10" style="padding: 10px">
					<el-table :data="formData.details" style="width:100% " height="calc(100vh - 600px)">
						<el-table-column label="序号" type="index" align="center" sortable width="80" />
						<el-table-column prop="materialName" label="物料名称" align="center" sortable />
						<el-table-column prop="materialCount" label="数量" align="center" sortable width="150" />
						<el-table-column prop="batchNo" label="批次号" align="center" sortable />
						<el-table-column align="center" sortable width="110" fixed="right" v-if="popType != 1">
							<template #header>
								<el-button :icon="Plus" @click="handleAddConfigLine">新建</el-button>
							</template>
							<template #default="scope">
								<el-button type="danger" plain :icon="Delete" @click="handleConfigDelete(scope.$index)"> 删除</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-row>
			</el-form>
			<template #footer>
        <span class="dialog-footer">
          <el-button @click="showDetail = false">关闭</el-button>
        </span>
			</template>
		</el-dialog>
		<!-- 点击入库弹窗 -->
		<el-dialog v-model="showOutIn" title="入库" width="1000px">
			<el-form :model="outInForm" :rules="outInRules" ref="outInFormRef" label-width="100px">
				<el-row :gutter="10">
					<el-col :span="8">
						<el-form-item label="物料名称"> {{ outInForm.materialName || '--' }}</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="批次号"> {{ outInForm.batchNo || '--' }}</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="数量" prop="materialCount" required>
							<el-input v-model="outInForm.materialCount" type="number" placeholder=""></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="入库仓库">
							<el-tree-select v-model="outInForm.targetWarehouseId" :data="wareList" check-strictly
															:render-after-expand="false" :props="{
                  children: 'sonList',
                  label: 'warehouseName',
                  value: 'id',
                }" @change="wareChange" />
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="入库库位" prop="targetStorageId" required>
							<el-select v-model="outInForm.targetStorageId" placeholder="请选择">
								<!--                sourceStorageId-->
								<el-option v-for="item in storageList" :key="item.id" :label="item.storageName" :value="item.id" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="二维码" prop="batchNo" required>
							<el-input v-model="outInForm.batchNo" placeholder=""></el-input>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<template #footer>
        <span class="dialog-footer">
          <el-button @click="showOutIn = false">取消</el-button>
          <el-button type="primary" @click="outInSum(outInFormRef)">保存</el-button>
        </span>
			</template>
		</el-dialog>
		<el-dialog title="二维码拆分" width="600px" v-model="qrCodeShow">
			<el-form label-width="auto">
				<el-form-item label="数量" required>
					<el-input-number v-model="qrCodeForm.count" :min="0" style="width: 50%;" />
				</el-form-item>
				<el-form-item label="备注">
					<el-input v-model="qrCodeForm.description" :rows="2" type="textarea" placeholder="请输入备注"></el-input>
				</el-form-item>
			</el-form>
			<template #footer>
				<div class="dialog-footer">
					<el-button @click="qrCodeShow = false">取 消</el-button>
					<el-button type="primary" @click="doQrCodeSplit">确 定</el-button>
				</div>
			</template>
		</el-dialog>
	</div>
</template>
<script lang="ts" setup>
import { ref, computed, watch, onMounted } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import axiosInstance from '@/utils/http/api';
import {
	Delete, Edit, Tickets, DocumentChecked
	, Search, Share, Upload, Refresh, Plus, DocumentCopy, Files, Download
} from '@element-plus/icons-vue';
import type { FormInstance, FormRules } from 'element-plus';

const paginatedData = ref([]);
const pageSize = ref(10);
const currentPage = ref(1);
const searchParam = ref({});
const handleSizeChange = (val) => {
	pageSize.value = val;
	getList();
};
const handleCurrentChange = (val) => {
	currentPage.value = val;
	getList();
};


const formData = ref({
	planNo: '',
	name: '',
	planBeginTime: null,
	planEndTime: null,
	actualBeginTime: null,
	actualEndTime: null,
	organizationId: '',
	status: '0',
	type: '0'
});

const crudTitle = computed(() => {
	if (popType.value === 1) {
		return '查看';
	} else {
		return isEdit.value ? '编辑' : '新建';
	}
});

const showDetail = ref(false);


// 重置搜索条件
const resetSearch = () => {
	searchParam.value = {};
	currentPage.value = 1;
	// currentPage.value = 1
	getList();
};

const procedureOrderList = ref({});
const wareList = ref({});
const storageList = ref({});
const materiaList = ref({});
const showOutIn = ref(false);
const outInForm = ref({
	materialName: '',
	batchNo: '',
	materialCount: '',
	wareId: '',
	targetStorageId: ''
});
const outInFormRef = ref(null);
const outInRules = reactive<FormRules<outInForm>>({
	materialCount: [
		{ required: true, message: '请输入数量', trigger: 'blur' }
	],
	wareId: [
		{ required: true, message: '请选择入库仓库', trigger: 'change' }
	],
	targetStorageId: [
		{ required: true, message: '请选择入库库位', trigger: 'change' }
	],
	batchNo: [
		{ required: true, message: '请选择批次号', trigger: 'blur' }
	]
});
const handleAddConfigLine = () => {
	formData.value.details.push({
		materialId: null,
		materialCount: null,
		batchNo: null
	});
};


const outFatherInfo = ref({});

const doOutIn = (row) => {
	const param = JSON.parse(JSON.stringify(row));
	outInForm.value = param;
	// this.materialCount = JSON.parse(JSON.stringify(param.materialCount))
	// 循环列表 找出子单据的父级
	// 提交时只提交父级和该条子单据

	for (const item of paginatedData.value) {
		if (item.children && item.children.length > 0) {
			for (const items of item.children) {
				if (items.id === row.id) {
					outFatherInfo.value = item;
					outInForm.value.targetWarehouseId = item.targetWarehouseId;
					outInForm.value.targetStorageId = item.targetStorageId;
					wareChange(item.targetWarehouseId);
				}
			}
		}
	}
	showOutIn.value = true;
};


const getSummaries = (param) => {
	const { columns, data } = param;
	const sums = [];

	// 初始化所有列的合计值为''
	columns.forEach((column, index) => {
		if (index === 0) {
			sums[index] = '合计';
			return;
		}
		sums[index] = '';
	});

	// 计算数量列的合计值
	const countIndex = columns.findIndex(column => column.property === 'count');
	if (countIndex !== -1) {
		const values = data.map(item => Number(item.count));
		sums[countIndex] = values.reduce((prev, curr) => {
			const value = Number(curr);
			if (!isNaN(value)) {
				return prev + curr;
			} else {
				return prev;
			}
		}, 0).toFixed(2);
	}

	return sums;
};


const handleConfigDelete = (e) => {
	formData.value.details.splice(e, 1);
};

const materialStatusList = ref([
	{
		value: 0,
		label: '未加工'
	},
	{
		value: 1,
		label: '已加工'
	}
]);

const wareChange = (e, type) => {
	if (!type) {
		formData.value.targetStorageId = null;
	}
	// storageList.value = {}
	axiosInstance.post('/api/basedataStorage/listByPojoPage', {
		warehouseId: e,
		current: 1,
		pageSize: 999999
	})
		.then((res) => {
			if (res.code !== 200) {
				ElMessage.warning(res.message);
				return false;
			}
			storageList.value = res.data.records;
		});
};

const multipleSelection = ref([]);

const handleSelectionChange = (val) => {
	multipleSelection.value = val;
};

import { getCurrentInstance } from 'vue';

const { proxy }: any = getCurrentInstance();

const qrCodeForm = ref({});
const qrCodeShow = ref(false);
const qrCodeSplit = () => {
	qrCodeForm.value = {
		id: multipleSelection.value[0].id
	};
	qrCodeShow.value = true;
};

const qrCodePush = () => {
	// element 二次确认
	ElMessageBox.confirm('确定合并二维码？', '提示', {
		confirmButtonText: '确定',
		cancelButtonText: '取消',
		type: 'warning'
	}).then(() => {
		const ids = multipleSelection.value.map(item => item.id);
		axiosInstance.post('/api/warehouseStorageMaterial/qrCodeMerge', ids)
			.then((res) => {
				if (res.code !== 200) {
					ElMessage.warning(res.message);
					return false;
				}
				ElMessage.success('操作成功');
				getList();
			});
	});
};

const doQrCodeSplit = () => {
	console.log(qrCodeForm.value);

	if (!qrCodeForm.value.count) {
		ElMessage.error('请输入拆分数量');
		return false;
	}

	axiosInstance.post('/api/warehouseStorageMaterial/qrCodeSplit', qrCodeForm.value)
		.then((res) => {
			if (res.code !== 200) {
				ElMessage.warning(res.message);
				return false;
			}
			ElMessage.success('操作成功');
			qrCodeShow.value = false;
			getList();
		});
};
// 打印 
const printClick = () => {
	for (const item of multipleSelection.value) {
		item.id = item.batchNo;
	}
	const templateName = 'test_print1/supplementTemplate.cpt';
	proxy.$printClick(templateName, multipleSelection.value);
};


const getOption = () => {
	axiosInstance
		.post('/api/basedataMaterial/getAll', {}).then(res => {
		if (res.code == 200) {
			const list = res.data;
			const loop = [];
			for (const item of list) {
				loop.push(
					{
						value: item.id,
						label: item.materialName
					}
				);
			}
			materiaList.value = loop;
		}
	});
	axiosInstance.post('/api/planProcedureOrder/getAll', {})
		.then(res => {
			if (res.code !== 200) {
				ElMessage.error(res.message);
				return false;
			}
			const list = res.data;
			const loop = [];
			for (const item of list) {
				loop.push(
					{
						value: item.id,
						label: item.materialName
					}
				);
			}
			procedureOrderList.value = list;
		});

	axiosInstance.get('/api/basedataWarehouse/treeList', {}).then(res => {
		if (res.code !== 200) {
			ElMessage.error(res.message);
			return false;
		}
		wareList.value = res.data;
	});

	// axiosInstance.post('/api/qualitySchemeTask/getPage', {})
	//     .then(res => {
	//       if (res.code !== 200) {
	//         ElMessage.error(res.message);
	//         return false
	//       }
	//       storageList.value = res.data
	//     })
};


const getTypeName = (type: string) => {
	const name = typeList.value.find((item: any) => item.value === type);
	return name ? name.label : '';
};

const typeList = ref([
	{ label: '未完成', value: '0' },
	{ label: '已完成', value: '1' }
]);

const isEdit = ref(false); // 是否编辑
const showCrud = ref(false); // 编辑/新建弹框

const transferType = ref({ status: 2 });

// 新建记录
const handleAdd = () => {
	popType.value = 0;
	isEdit.value = false;
	formData.value = {
		details: [{
			materialId: null,
			materialCount: null,
			batchNo: null
		}]
	};
	showCrud.value = true;
};


const popType = ref(0);//0 编辑 1 只读


const statusList = ref([{
	label: '不可用',
	value: 0
}, {
	label: '可用',
	value: 1
}, {
	label: '运输中',
	value: 2
}, {
	label: '生产锁定',
	value: 3
}, {
	label: '不合格',
	value: 4
}, {
	label: '报废',
	value: 5
}]);

const formatStatus = (row, column, cellValue) => {
	switch (cellValue) {
		case 0:
			return '不可用';
		case 1:
			return '可用';
		case 2:
			return '运输中';
		case 3:
			return '生产锁定';
		case 4:
			return '不合格';
		case 5:
			return '报废';
	}
};

const formatProcessingAttributes = (row, column, cellValue) => {
	switch (cellValue) {
		case 0:
			return '未加工';
		case 1:
			return '已加工';

	}
};

const rejectShow = ref({});

// 编辑记录
const
	handleEdit = (row: any, type) => {
		// console.log(row,'czqRow')
		ElMessageBox.prompt('请输入驳回原因', '驳回', {
			confirmButtonText: '确认',
			cancelButtonText: '取消'
		})
			.then(({ value }) => {
				row.remark = value;
				const param = {
					id: row.materialTransferOrderId,
					code: row.orderNo,
					details: [row],
					tasks: [row]
				};
				axiosInstance.post('/api/warehouseMaterialTransferOrder/reject', param).then((res) => {
					if (res.code === 200) {
						getList();
						ElMessage.success('驳回成功');

					} else {
						ElMessage.warning(res.message);
					}
				});
			});
		// isEdit.value = true;
		// formData.value = {...row};
		// axiosInstance.post('/api/warehouseMaterialTransferOrder/getDetailById', {id: row.id}).then(res => {
		//   if (res.code !== 200) {
		//     ElMessage.warning(res.message);
		//     return false;
		//   }
		//   formData.value.details = res.data.children
		//   if (type) {
		//     // 查看详情
		//     popType.value = type
		//     showDetail.value = true
		//   } else {
		//     // 编辑
		//     popType.value = 0
		//     showCrud.value = true;
		//   }
		//   wareChange(e.targetWarehouseId)
		// })
	};


// 保存记录
const handleSave = async () => {
	const param = formData.value;
	if (param.details.length == 0) {
		ElMessage.warning('请选择物料');
		return false;
	}
	for (const item of param.details) {
		if (!item.materialId) {
			ElMessage.warning('请选择物料');
			return false;
		}
		if (!item.materialCount || item.materialCount === 0) {
			ElMessage.warning('请输入数量');
			return false;
		}


	}
	axiosInstance.post('/api/warehouseMaterialTransferOrder/save', { ...param, ...transferType.value })
		.then((res) => {
			if (res.code !== 200) {
				ElMessage.error(res.message);
				return false;
			}
			showCrud.value = false;
			getList();
		});
};

// 展开行处理
const expandedRowKeys = ref<string[]>([]);
const handleExpandChange = (row: any, expandedRows: any[]) => {
	if (expandedRows.includes(row)) {
		rowChildren(row);
	} else {
		// getList();
	}
};

const rowChildren = (row: any) => {
	axiosInstance.post('/api/warehouseMaterialTransferOrder/getDetailById', { id: row.id }).then(res => {
		if (res.code !== 200) {
			ElMessage.warning(res.message);
			return false;
		}
		const listGroup = paginatedData.value.map((item) => {
			if (item.id === row.id) {
				return { ...item, children: res.data.children };
			}
			return item;
		});
		paginatedData.value = listGroup;
	});
	// axiosInstance.post('/api/basedataQualityScheme/getAll', {planId: row.id})
	//     .then(res => {
	//       if (res.code !== 200) {
	//         ElMessage.error(res.message);
	//         return false
	//       }
	//
	//       .value = res.data
	//     });

	// ProductionPlanDetailApi().then((res) => {
	//   if (res.code !== 200) {
	//     ElMessage.warning(res.message);
	//     return false;
	//   }
	//   const listGroup = paginatedData.value.map((item) => {
	//     if (item.id === row.id) {
	//       return {...item, children: res.data.records};
	//     }
	//     return item;
	//   });
	//   paginatedData.value = listGroup;
	// });
};

const pageTotal = ref(0);


// 获取列表
const getList = async () => {
	axiosInstance.post('/api/warehouseStorageMaterial/pageByBatch', {
		...searchParam.value,
		current: currentPage.value,
		pageSize: pageSize.value
	})
		.then(res => {
			if (res.code !== 200) {
				ElMessage.error(res.message);
				return false;
			}
			paginatedData.value = res.data.records.map((item) => ({
				...item,
				children: [],
				layer: 1,
				_loading: false
			}));
			pageTotal.value = res.data.total;
		});
};

onMounted(() => {
	getList();
	getOption();
});
</script>
<style scoped lang="scss"></style>
